<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>销售页面</title>
    <link href="${pageContext.request.contextPath}/css/sales/sales.css" rel="stylesheet">
    <script src="${pageContext.request.contextPath}/dist/jquery-3.6.0.min.js" rel="stylesheet"></script>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/dist/layui/css/layui.css">
</head>
<body>
<!--导航条-->
<c:import url="/header/header.jsp"/>
<!--主要内容-->
<div class="container">
    <div class="wrapper">
        <div class="sales-info">
            <div class="info-l">
                <div class="sales-img">
                    <img src="${pageContext.request.contextPath}/images/sales/wKgE2l0sMDCASSrVAAPIx4JY7lc94.jpeg">
                </div>
                <!--日历-->
                <div class="sales-calendar">
                    <div class="calendar-year-month">
                        <span class="left"><i></i></span>
                        <span class="right"><i></i></span>
                        <div class="month">
                            <ul class="month-ul">
                                <li class="month-tab-9 month-tab">

                                </li>
                                <li class="month-tab-10 ">

                                </li>
                                <li class="month-tab-11">

                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="calendar-month-day">
                        <ul class="week">
                            <li>日</li>
                            <li>一</li>
                            <li>二</li>
                            <li>三</li>
                            <li>四</li>
                            <li>五</li>
                            <li>六</li>
                        </ul>
                        <ul class="day">
                        </ul>
                    </div>
                </div>
                <!--收藏-->
                <div class="sales-collection">
                    <a class="collection">
                        <i></i>
                        <span class="isCollection">收藏</span>
                    </a>
                </div>
                <script>
                    var custId = '${loginCustomer.custId}';
                    console.log("用户Id："+custId)
                    var url = "${pageContext.request.contextPath}/collection/isCollection";
                    $.get(
                        url,
                        {"custId":custId},
                        function (result){
                            console.log(result);
                            for (let i = 0; i < result.data.length; i++) {
                                if(result.data[i]===${response.data.travelSightsId}){
                                    $(".isCollection").text("已收藏");
                                    break;
                                }
                            }
                        },
                        "json"
                    )
                    $(".collection").click(function (){
                        if($(".isCollection").text()==="收藏" && custId!==''){
                            var url = "${pageContext.request.contextPath}/collection/addCollection";
                            $.post(
                                url,
                                {"custId":custId,
                                "sightsId":${response.data.travelSightsId}
                                },
                                function (result){
                                    $(".isCollection").text("已收藏!");
                                    alert("收藏成功!")
                                }
                            )
                        }else if(custId!==''){
                            alert("已收藏!")
                        }else {
                            alert("请先登录!")
                        }
                    })
                </script>
            </div>
            <div class="info-r">
                <div class="sales-title">
                    <span id="${response.data.travelSightsId}">景点</span>
                    <h1 class="travelName">${response.data.travelSightsName}</h1>
                </div>
                <div class="sales-price-info">
                    <ul>
                        <li class="info-price">
                            <em>￥</em>
                            <strong>${response.data.travelTicketsPrice}</strong>
                        </li>
                        <li class="info-number">
                            <em>已赞</em>
                            <strong>${response.data.travelSightsPraiseCount}</strong>
                        </li>
                    </ul>
                </div>
                <div class="sales-tip">
                    <span>预定须知</span>
                    <p>支付完成后商家最晚会在2个工作小时内（工作日9:00-18:00）确认是否预定成功</p>
                </div>
                <div class="r-line"></div>
                <div class="sales-panel">
                    <ul>
                        <li class="date">
                            <label>出行日期</label>
                            <a>
                                <span class="datetime"></span>
                            </a>

                        </li>
                        <%--                        <li class="day">--%>
                        <%--                            <label>出行天数</label>--%>
                        <%--                            <a>--%>
                        <%--                                <span class="dateday">5</span>天--%>
                        <%--                            </a>--%>
                        <%--                        </li>--%>
                        <li>
                            <label>出行人数</label>
                            <ul class="person-number">
                                <li class="adult-amount">
                                    <div class="amount">
                                            <span class="input-adult">
                                                <span class="adult">成人</span>
                                                <span class="number adultNumber">1</span>
                                            </span>
                                        <span class="up-down">
                                                <a class="up">
                                                    <button>+</button>
                                                </a>
                                                <a class="down">
                                                    <button>-</button>
                                                </a>
                                            </span>
                                    </div>
                                </li>
                                <li class="child-amount">
                                    <div class="amount">
                                            <span class="input-child">
                                                <span class="child">儿童</span>
                                                <span class="number childNumber">0</span>
                                            </span>
                                        <span class="up-down">
                                                <a class="up">
                                                    <button>+</button>
                                                </a>
                                                <a class="down">
                                                    <button>-</button>
                                                </a>
                                            </span>
                                    </div>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
                <div class="purchase">
                    <div class="fri-price">
                        <em>￥</em>
                        <strong class="price1">--</strong>
                    </div>
                    <span class="purchase-btn">
                            <a href="${pageContext.request.contextPath}/submit_order/submit_order.jsp">立即购买</a>
                    </span>
                </div>
            </div>
            <div class="review">
                <div class="logo">
                </div>
                <h2>用户评论</h2>
                <div class="review-border">
                    <div class="review-lists">
                        <ul class="review-item">

                        </ul>
                    </div>
                    <div id="page"></div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--底部-->
<div class="footer"></div>
<script src="${pageContext.request.contextPath}/js/sales/sales.js"></script>
<script>
    $(".purchase-btn").click(function () {
        var customer = "<%=request.getSession().getAttribute("loginCustomer")%>";
        console.log("++++++++++++++++++++++" + customer);
        console.log('${loginCustomer}');
        if( customer == "null"){
            alert("请先完成登录");
            window.location.href ="${pageContext.request.contextPath}/customer/login.jsp";
            window.event.returnValue=false;
        }else {
            var date = $(".datetime").text();
            console.log("=====================================");
            console.log("date的类型:" + typeof (date));
            console.log(date);
            var day = $(".dateday").text();
            console.log("day的类型:" + typeof (day));
            console.log(day);

            var audltNum = $(".adultNumber").text();
            console.log(audltNum);
            console.log("audltNum的类型:" + typeof (audltNum));

            var childNum = $(".childNumber").text();
            console.log(childNum);

            var pricecost = $(".price1").text();
            console.log("pricecost:" + pricecost);

            // var data = [day, date, audltNum, childNum, pricecost];
            // console.log("data:" + data);

            sessionStorage.setItem("day", day);
            sessionStorage.setItem("date", date);
            sessionStorage.setItem("audltNum", audltNum);
            sessionStorage.setItem("childNum", childNum);
            sessionStorage.setItem("pricecost", pricecost);
        }
    });

    var travelName = $(".travelName").text();
    console.log(travelName);
    sessionStorage.setItem("travelName", travelName);

</script>
<script src="${pageContext.request.contextPath}/dist/layui/layui.js"></script>
</body>

</html>
